# -*- coding: utf-8 -*-
"""
@Time ： 2024/4/19 13:45
@Auth ： 李天天
"""
import requests
import time
from Common.basepage import BasePage
from PageObjects.Main_page import MainPage
from PageObjects.Player_page import PlayerPage
from Common.connect_to_device import *


def start_multirender():
    # BasePage(device="d_one").press_key("home")
    # pass
    # BasePage(device="d_one").press_key("back")
    # BasePage(device="d_one").start_middleware_app()
    # time.sleep(3)
    MainPage(device="d_one").click_start_play()
    time.sleep(3)
    MainPage(device="d_one").click_start_share()
    time.sleep(2)
    MainPage(device="d_one").select_screen()
    time.sleep(1)
    MainPage(device="d_one").click_ok()


def back_to_main():
    PlayerPage(device="d_one").click_back()
    # BasePage(device="d_one").press_key("back")


def press_invite():
    # BasePage(device="d_one").press_key("home")
    while True:
        start_multirender()
        time.sleep(3)
        # BasePage(device="d_three").save_img_for_player("平板起播截图")
        time.sleep(5)
        back_to_main()
        time.sleep(2)


if __name__ == '__main__':
    while True:
        try:
            press_invite()
        except:
            try:
                back_to_main()
                requests.get(url="https://api.day.app/s3KoLFVvWVWdYiiro2gKW/多画布自动操作脚本可能出现问题")
            except:
                pass
